<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/fingerprint.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/jquery-1.10.1.min.js",CClientScript::POS_HEAD);
//Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.core.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.scroller.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.util.datetime.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.datetimebase.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.ios.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.i18n.zh.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/css/bootstrap.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.animation.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.widget.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.widget.ios.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.scroller.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.scroller.ios.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);
?>
<style>
    .child_zw{
        cursor:pointer;
    }
    .form-control {
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
        color: #555;
        font-size: 14px;
        height: 34px;
        line-height: 1.42857;
        padding: 6px 12px;
        transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
        width: 86%;
        display: inline-block;
    }
    .fa{
        width: 36px;
    }
    .Cbox label{
        width: 90px;
    }
    .Cbox label input{
        margin-right: 5px;
    }
</style>
<header class="homeHder header">
    <div class="hder_logo">课堂观测创建随堂课</div>
</header>
<section class="cont_wrpa pdX10">

        <div class="modl_tel">
            <i class="fa fa-graduation-cap"></i>
            <input id="title1" value="" type="text" placeholder="随堂课名称">
        </div>
        <div class="modl_tel">
            <i class="fa fa-user"></i>
            <input id="room" value=""  type="text" placeholder="教室">
        </div>
        <div class="modl_tel">
            <i class="fa fa-lock"></i>
            <input id="open_time" value=""  type="number" placeholder="课程总时长【分钟】">
        </div>
        <div class="modl_tel">
            <i class="fa fa-lock"></i>
            <input id="start_time" value=""  type="text" placeholder="开始时间">
        </div>
        <div class="modl_tel">
            <i class="fa fa-lock"></i>
            <input id="end_time" value=""  type="text" placeholder="结束时间">
        </div>
    <div class="">
        讲课老师
        <div class="Cbox">
            <?php if($techer){ ?>
                <?php foreach($techer as $v){ ?>
                    <label><input type="radio" value="<?php echo $v->id ?>" class="jk" name="jk"><?php echo $v->user_name ?></label>
                <?php }} ?>
            <div class="clear" style="z-index: 670;"></div>
        </div>
    </div>
        <div class="">
            听课老师
            <div class="Cbox">
                <?php if($techer){ ?>
                    <?php foreach($techer as $v){ ?>
                        <label><input type="checkbox" value="<?php echo $v->id ?>" class="tk" name="tk"><?php echo $v->user_name ?></label>
                <?php }} ?>
                <div class="clear" style="z-index: 670;"></div>
            </div>
        </div>
    <div class="">
        观察员
        <div class="Cbox">
            <?php if($techer){ ?>
                <?php foreach($techer as $v){ ?>
                    <label><input type="checkbox" value="<?php echo $v->id ?>" class="gc" name="gc"><?php echo $v->user_name ?></label>
                <?php }} ?>
            <div class="clear" style="z-index: 670;"></div>
        </div>
    </div>

    <div class="go">
        <a id="login1" href="javascript:void(0);">立即创建</a>
    </div>
</section>
<br><br><br>
<script>
    $(function(){
        $("#login1").click(function(){
            var _this = $(this);
            var title = $("#title1").val();
            var room = $("#room").val();
            var open_time = $("#open_time").val();
            var start_time = $("#start_time").val();
            var end_time = $("#end_time").val();
            var tk = $("input[name='tk']:checked").serialize();
            var gc = $("input[name='gc']:checked").serialize();
            var zj = $("input[name='zj']:checked").serialize();
            var jk = $('input:radio[name="jk"]:checked').val();
            if(title ==''){
                alert('随堂课名称不得为空');
                return false;
            }
            if(title.length < 2){
                alert('随堂课名称不得小于2位');
                return false;
            }
            if(title.length > 40){
                alert('随堂课名称不得大于40位');
                return false;
            }
            if(room ==''){
                alert('教室不得为空');
                return false;
            }
            if(open_time ==''){
                alert('上课时长不得为空');
                return false;
            }
            if(start_time ==''){
                alert('开始时间不得为空');
                return false;
            }
            if(end_time ==''){
                alert('结束时间不得为空');
                return false;
            }
            if(tk==''){
                alert('请选择听课老师');
                return false;
            }
            if(gc==''){
                alert('请选择观察员');
                return false;
            }
//            if(zj==''){
//                alert('请选择专家');
//                return false;
//            }

            $.ajax({
                type: "POST",
                url: '<?php echo Yii::app()->createUrl('observation/ajaxCreateOpen') ?>',
                data: {
                    title:title,
                    room:room,
                    open_time:open_time,
                    start_time:start_time,
                    end_time:end_time,
                    tk:tk,
                    gc:gc,
                    jk:jk
                },
                dataType: "json",
                beforeSend: function () {
                    _this.css('background','#ccc');
                    _this.html('<i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;&nbsp;正在创建中');
                },
                success: function (data) {
                    if (data) {
                        if (data['status'] == 1) {
                            window.location.href='<?php echo Yii::app()->createUrl('observation/list',array('openid'=>$openid)) ?>';
                        } else {
                            alert(data['message']);
                            _this.css('background','#68c8c7');
                            _this.html('立即创建');
                            return false;
                        }
                    }
                }
            });
        });

    })
</script>

<script type="text/javascript">
    $(function () {
        var nowData=new Date();
        var opt1= {
            theme:'ios', //设置显示主题
            mode:'scroller', //设置日期选择方式，这里用滚动
            display:'bottom', //设置控件出现方式及样式
            preset : 'date', //日期:年 月 日 时 分

            maxDate:new Date(nowData.getFullYear(),nowData.getMonth()+2,nowData.getDate()+7,23),
//            maxDate:new Date(nowData.getFullYear(),nowData.getMonth()+2,nowData.getDate()+7,22,00),
//              dateFormat: 'yy-mm-dd', // 日期格式
//              dateOrder: 'yymmdd', //面板中日期排列格式
            stepMinute: 10, //设置分钟步长
            yearText:'年',
            monthText:'月',
            dayText:'日',
            hourText:'时',
            minuteText:'分',
            lang:'zh' //设置控件语言};
        };

        var currYear = (new Date()).getFullYear();
        var currMonth = (new Date()).getMonth();
        var opt={};
        opt.date = {preset : 'date'};
        opt.datetime = {preset : 'datetime'};
        opt.time = {preset : 'time'};
        opt.default = {
            theme: 'ios', //皮肤样式
            display:'bottom',
            mode: 'scroller', //日期选择模式
            dateFormat: 'yyyy-mm-dd',
            lang: 'zh',
            showNow: true,
            nowText: "今天",
            startYear: currYear, //开始年份
            endYear: currYear + 1//结束年份
        };
        var optDateTime = $.extend(opt['datetime'], opt['default']);
        $('#start_time').mobiscroll(optDateTime);
        $('#end_time').mobiscroll(optDateTime);
    });
</script>

